﻿<DemoContainer>
    <ApexChart TItem="Order"
               Title="Order Net Value" Options="options">

        <ApexPointSeries TItem="Order"
                         Items="Orders"
                         Name="Gross Value"
                         SeriesType="SeriesType.Line"
                         XValue="@(e => e.Country)"
                         YAggregate="@(e => e.Sum(e => e.GrossValue))"
                         OrderByDescending="e=>e.Y" />

        <ApexPointSeries TItem="Order"
                         Items="Orders"
                         Name="Net Value"
                         SeriesType="SeriesType.Line"
                         XValue="@(e => e.Country)"
                         YAggregate="@(e => e.Sum(e => e.NetValue))"
                         OrderByDescending="e=>e.Y" />
    </ApexChart>
</DemoContainer>

@code {
    private List<Order> Orders { get; set; } = SampleData.GetOrders();
    private ApexChartOptions<Order> options { get; set; } = new();

    protected override void OnInitialized()
    {

        var downloadIcon = @"<svg xmlns='http://www.w3.org/2000/svg'  width='20' height='20' viewBox='0 0 24 24' stroke-width='2' stroke='currentColor' fill='none' stroke-linecap='round' stroke-linejoin='round'>
   <path stroke='none' d='M0 0h24v24H0z' fill='none'></path>
   <path d='M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2'></path>
   <path d='M7 11l5 5l5 -5'></path>
   <path d='M12 4l0 12'></path>
</svg>";

        options.Chart = new Chart
            {
                Toolbar = new ApexCharts.Toolbar
                {
                    Tools = new Tools { Download = downloadIcon }
                }
            };


        base.OnInitialized();
    }

}